# Build the vtk-gdcm simple viewer
INCLUDE_DIRECTORIES(
  ${GDCM_SOURCE_DIR}/Utilities/VTK
  )

SET(GDCM_VTK_APPS
  gdcmviewer # vtkImageViewer2
  )
IF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" GREATER 5.0 )
  SET(GDCM_VTK_APPS
    ${GDCM_VTK_APPS}
    gdcmorthoplanes
    gdcm2vtk
    gdcmscene
  )
ENDIF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" GREATER 5.0 )

FOREACH(app ${GDCM_VTK_APPS})
  ADD_EXECUTABLE(${app} ${app}.cxx)
  SET_TARGET_PROPERTIES(${app} PROPERTIES ${GDCM_EXECUTABLE_PROPERTIES})
  TARGET_LINK_LIBRARIES(${app} vtkgdcm vtkRendering)
  IF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" GREATER 5.0 )
    TARGET_LINK_LIBRARIES(${app} vtkgdcm vtkWidgets)
  ENDIF( "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" GREATER 5.0 )
  IF(NOT GDCM_INSTALL_NO_LIBRARIES)
    INSTALL(TARGETS ${app}
      RUNTIME DESTINATION ${GDCM_INSTALL_BIN_DIR} COMPONENT Runtime
      LIBRARY DESTINATION ${GDCM_INSTALL_LIB_DIR} COMPONENT Runtime
      ARCHIVE DESTINATION ${GDCM_INSTALL_LIB_DIR} COMPONENT Development
    )
  ENDIF(NOT GDCM_INSTALL_NO_LIBRARIES)
ENDFOREACH(app)

IF(CMAKE_HAVE_PTHREAD_H)
# Dev only: I dont need to install that one:
  ADD_EXECUTABLE(threadgdcm threadgdcm.cxx)
  TARGET_LINK_LIBRARIES(threadgdcm gdcmMSFF pthread vtkIO)
ENDIF(CMAKE_HAVE_PTHREAD_H)

#ADD_EXECUTABLE(gdcm2vtk gdcm2vtk.cxx)
#TARGET_LINK_LIBRARIES(gdcm2vtk gdcmMSFF pthread)


